package org.domain.projeto.converter;

import java.text.ParseException;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.swing.text.MaskFormatter;

public class CepConverter implements Converter {

	@Override
	public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
		return null;
	}

	@Override
	public String getAsString(FacesContext context, UIComponent component, Object object) {
		MaskFormatter mf = null;
		try {
			mf = new MaskFormatter("#####-###");
			mf.setValueContainsLiteralCharacters(false);
			return mf.valueToString(object);
		} catch (ParseException e) {
			return null;
		}
	}

}
